package com.tianyalei.wolf.sample.activity.imageload;

import android.content.Intent;
import android.os.Bundle;

import com.facebook.drawee.view.SimpleDraweeView;
import com.tianyalei.wolf.sample.R;
import com.tianyalei.wolf.sample.activity.base.BaseToolBarActivity;
import com.tianyalei.wolf.sample.imageload.ImageLoadProxy;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ImageLoadActivity extends BaseToolBarActivity {

    @Bind(R.id.image)
    SimpleDraweeView image;
    @Bind(R.id.image1)
    SimpleDraweeView image1;


    //    String demoUri = "http://f.hiphotos.baidu.com/image/h%3D200/sign=d9c2d17b1a950a7b6a3549c43ad0625c/14ce36d3d539b600af3985faee50352ac75cb78c.jpg";
    String demoUri = "http://ww2.sinaimg.cn/large/85cccab3tw1esjq9r0pcpg20d3086qtr.gif";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);

        ImageLoadProxy.displayImage(demoUri, image);

        ImageLoadProxy.displayImage(demoUri, image1);

//        Uri uri = Uri.parse(demoUri);
////        image.setImageURI(uri);
//        DraweeController controller = Fresco.newDraweeControllerBuilder().setUri(uri).setTapToRetryEnabled(true)
//                .setControllerListener(new BaseControllerListener<ImageInfo>() {
//                    @Override
//                    public void onFailure(String id, Throwable throwable) {
//                        super.onFailure(id, throwable);
//                        ToastUtil.showToast(ImageLoadActivity.this, "失败了");
//                    }
//                }).build();
//        image.setController(controller);
//        image1.setImageURI(uri);
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_image_load;
    }


    @OnClick(R.id.image)
    public void onClick() {
        Intent intent = new Intent(this, ImageDetailActivity.class);
        intent.putExtra("url", demoUri);
        startActivity(intent);
    }
}
